package com.dragonsky.shop.user.controller;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.nacos.api.NacosFactory;
import com.alibaba.nacos.api.config.ConfigService;
import com.dragonsky.shop.common.utils.AjaxResult;
import com.dragonsky.shop.openfeign.user.UserFeign;
import com.dragonsky.shop.openfeign.user.param.UserInfoParam;
import com.dragonsky.shop.openfeign.user.vo.UserInfoVo;
import com.dragonsky.shop.user.domain.vo.StarListVo;
import com.dragonsky.shop.user.domain.vo.UserNaCosVo;
import com.dragonsky.shop.user.service.UserService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Properties;

/**
 * <p>
 * 用户表 前端控制器
 * </p>
 *
 * @author dragon
 * @since 2025-03-22 00:13:28
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    @Resource
    private UserFeign userFeign;


    @GetMapping("/test")
    public String test() {
        return userService.test();
    }

    @GetMapping("/getNaCosConfig")
    public AjaxResult<UserNaCosVo> getNaCosConfig() {
        return userService.getNaCosConfig();
    }

    @GetMapping("/starList")
    // @SentinelResource
    public AjaxResult<List<StarListVo>> getStarList() {
        return userService.getStarList();
    }

    @GetMapping("/seata")
    public AjaxResult<Void> seata() throws InterruptedException {
        return userService.seata();
    }

    @GetMapping("/userName")
    AjaxResult<String> userName(@RequestParam(value = "userName", required = false) String userName) {
        return userFeign.userName(userName);
    }

    @GetMapping("/userInfo")
    AjaxResult<UserInfoVo> userInfo(UserInfoParam userInfoParam) {
        return userFeign.userInfo(userInfoParam);
    }

    @PostMapping("/userInfo2")
    AjaxResult<UserInfoVo> userInfo2(UserInfoParam userInfoParam) {
        return userFeign.userInfo2(userInfoParam);
    }

    @PostMapping("/userInfo3")
    AjaxResult<UserInfoVo> userInfo3(@RequestBody UserInfoParam userInfoParam) {
        return userFeign.userInfo3(userInfoParam);
    }

}
